package com.alcatel_lucent.osp.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import java.util.Properties;

/**
 * User: Guoshun Wu
 * Date: 13-8-29
 * Time: 下午9:40
 */

@Configuration
public class ThirdVelocityEmailAppConfig {
    private
    @Value("${smtp.host}")
    String smtpHost;

    private
    @Value("${smtp.port}")
    Integer smtpPort;

    private
    @Value("${smtp.auth}")
    String mailAuth;

    public @Bean
    JavaMailSender mailSender(){
        JavaMailSenderImpl ms = new JavaMailSenderImpl();
        ms.setHost(smtpHost);
        ms.setPort(smtpPort);
//        ms.setUsername("test@126.com");
//        ms.setPassword("gaga");
        Properties pp = new Properties();
        pp.setProperty("mail.smtp.auth", mailAuth);
        ms.setJavaMailProperties(pp);
        return ms;
    }
}
